import request from '@/utils/request';
import { AxiosResponse } from 'axios';
import { inspectionPointsForm } from '@/api/inspection/spot/types';

type RES = Promise<AxiosResponse>;
type PAM = { [n: string]: string };

/**
 * 查询巡检点列表
 * @param query
 * @returns {*}
 */

export const inspectionSpotList = (query?: string): RES => {
  return request({
    url: '/inspection/spot/list',
    method: 'get',
    params: query
  });
};

/**
 * 创建巡检点接口
 *
 * @param params 巡检点表单数据
 * @returns 返回请求结果
 */
export const ApiCreateInspectionSpot = (params: inspectionPointsForm): RES => {
  return request({
    url: '/inspection/spot',
    method: 'post',
    data: params
  });
};

/**
 * 获取巡检点详情
 *
 * @param query 查询参数，可选
 * @returns 返回API请求结果
 */
export const ApiGetInspectionSpotDetail = (id?: string | number): RES => {
  return request({
    url: '/inspection/spot/' + id,
    method: 'get'
  });
};

/**
 * 修改巡检点接口
 *
 * @param params 巡检点表单数据
 * @returns 返回请求结果，类型为 RES
 */
export const ApiUpdateInspectionSpot = (params: inspectionPointsForm): RES => {
  return request({
    url: '/inspection/spot',
    method: 'put',
    data: params
  });
};

/**
 * 删除巡检点
 *
 * @param query 查询参数，可选
 * @returns 返回API请求结果
 */
export const ApiDeleteInspectionSpot = (id?: string | number): RES => {
  return request({
    url: '/inspection/spot/' + id,
    method: 'delete'
  });
};
